/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2010
 */

package com.tech15.pub.model;

import javacommon.base.BaseEntity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.validator.constraints.Length;

import com.tech15.core.model.SysUser;


/**
 * @author badqiu email:badqiu(a)gmail.com
 * @version 1.0
 * @since 1.0
 */


@Entity
@Table(name = "PUB_GROUP_USER")
public class PubGroupUser extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "PrivilegeGroupUser";
	public static final String ALIAS_PGUID = "组成员序号";
	public static final String ALIAS_PGID = "组序号";
	public static final String ALIAS_USERID = "用户序号";
	//date formats

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * 组成员序号       db_column: PGUID 
     */ 	
	
	private Long pguid;
    /**
     * 组序号       db_column: PGID 
     */ 	
	
	private Long pgid;
    /**
     * 用户序号       db_column: USERID 
     */
	@Length(max=32)
	private Long userid;
	//columns END


	public PubGroupUser(){
	}

	public PubGroupUser(
		Long pguid
	){
		this.pguid = pguid;
	}

	

	public void setPguid(Long value) {
		this.pguid = value;
	}
	
	@Id @GeneratedValue(generator="custom-id")
	@GenericGenerator(name="custom-id", strategy = "increment")
	@Column(name = "PGUID", unique = true, nullable = false, insertable = true, updatable = true, length = 22)
	public Long getPguid() {
		return this.pguid;
	}
	
	@Column(name = "PGID", unique = false, nullable = true, insertable = true, updatable = true, length = 22)
	public Long getPgid() {
		return this.pgid;
	}
	
	public void setPgid(Long value) {
		this.pgid = value;
	}
	
	@Column(name = "USERID", unique = false, nullable = true, insertable = true, updatable = true, length = 32)
	public Long getUserid() {
		return this.userid;
	}
	
	public void setUserid(Long value) {
		this.userid = value;
	}
	
	private PubGroup pubGroup;
	public void setGroup(PubGroup pubGroup){
		this.pubGroup = pubGroup;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "PGID",nullable = false, insertable = false, updatable = false) 
	})
	public PubGroup getGroup() {
		return pubGroup;
	}
	
	private SysUser user;
	public void setUser(SysUser user){
		this.user = user;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "USERID",nullable = false, insertable = false, updatable = false) 
	})
	public SysUser getUser() {
		return user;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("Pguid",getPguid())
			.append("Pgid",getPgid())
			.append("Userid",getUserid())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getPguid())
			.toHashCode();
	}
	private String realName;
	private String orgInfo;
	private String groupName;
	private String username;
	private Long id;
	private String name;

	@Transient
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Transient
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Transient
	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Transient
	public String getOrgInfo() {
		return orgInfo;
	}

	public void setOrgInfo(String orgInfo) {
		this.orgInfo = orgInfo;
	}

	@Transient
	public String getRealName() {
		return realName;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}
	@Transient
	public String getGroupName() {
		return groupName;
	}

	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}
}

